<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
    <meta http-equiv="X-UA-Compatible" content="IE=Edge">
    <style>
        body,
        html,
        #container {
            overflow: hidden;
            width: 100%;
            height: 100%;
            margin: 0;
            font-family: "微软雅黑";
        }
    </style>
    <script src="//api.map.baidu.com/api?type=webgl&v=1.0&ak=Bsj96BKbDsFNrHiyHsyegFEQpPu5btnG"></script>
    <script src="js/axios-0.18.0.js"></script>
    <script src="js/vue-2.6.12.js"></script>
    <!--使用element-ui之前要先引入vue，他是基于vue的-->
    <script src="js/vuejs-2.5.16.js"></script>
    <!--引入element-ui的样式-->
    <link rel="stylesheet" href="element-ui/lib/theme-chalk/index.css">
    <!--引入element-ui的js文件-->
    <script src="element-ui/lib/index.js"></script>
    <!--引入axios-->
    <script src="js/axios-0.18.0.js"></script>
</head>
<body>

<div id="userDetails">
    <div>
        <div class="block">
            <table>
                <tr>
                    <td>
                        <el-avatar shape="square" :size="100" :src="userLocation.avatar"></el-avatar>
                    </td>
                    <td>
                        <ul class="userInfo">
                            <li>
                                <font color="aqua">昵 称</font>: {{userLocation.nickname}}
                            </li>
                            <li>
                                <font color="aqua">性 别</font>: {{userLocation.gender}}
                            </li>
                            <li>
                                <font color="aqua">城 市</font>: {{userLocation.city}}
                            </li>
                            <li>
                                <font color="aqua">地 址</font>: {{userLocation.address}}
                            </li>
                        </ul>
                    </td>
                </tr>
            </table>
        </div>
    </div>
</div>
<div id="container"></div>
</body>

<script>
    const app = new Vue({
        el: '#userDetails',
        data: {
            userLocation: { // 用户对象
                userId: 110,//用户id
                nickname: "",//用户昵称
                avatar: "",//用户头像
                gender: "",//性别
                city: "",//城市
                address: "",//地址
                longitude: 0.0,//经度
                latitude: 0.0,//纬度
            },
        },

        methods: {
            // 信息查询
            findUserMessages(userId) {
                axios.get('/findUserMessages?userId='+userId).then(resp => {
                    this.userLocation = resp.data;
                    var map = new BMapGL.Map('container'); // 创建Map实例
                    var marker = new BMapGL.Marker(new BMapGL.Point(this.userLocation.longitude,this.userLocation.latitude));
                    map.centerAndZoom(new BMapGL.Point(this.userLocation.longitude,this.userLocation.latitude), 12); // 初始化地图,设置中心点坐标和地图级别
                    map.enableScrollWheelZoom(true); // 开启鼠标滚轮缩放
                    map.addOverlay(marker); // 增加点
                })
            },
        },
        created() {
            let userId=location.search.split("=")[1];
            // 页面加载成功
            this.findUserMessages(userId)
        }
    })
</script>